package com.example.shop_2304.welfg

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.callback.NavigationCallback
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.SPUtils
import com.example.base.mvvm.BaseViewFragment
import com.example.shop_2304.R
import com.example.shop_2304.databinding.FragmentBlank3Binding

/**
 * 使用ARouter的拦截器用来统一处理要跳转的界面，需要登录且未登录，都给跳转到登录界面，不需要登录或者已经登录了，都想跳转到哪就跳转到哪
 */
class BlankFragment3 : BaseViewFragment<FragmentBlank3Binding>() {
    override fun initView() {
        binding.btnIn.setOnClickListener {
          /*  if(SPUtils.getInstance().getString("token").isNotEmpty()){
                ARouter.getInstance().build("/app/MainActivity").navigation()
            }else{
                ARouter.getInstance().build("/app/LoginActivity").navigation()
            }*/

            ARouter.getInstance().build("/app/MainActivity").navigation(context,object :NavigationCallback{
                override fun onFound(postcard: Postcard?) {
                   //找到
                }

                override fun onLost(postcard: Postcard?) {
                    //迷失   找不到对应路径
                }

                override fun onArrival(postcard: Postcard?) {
                    //到达   跳转到指定页面
                    activity?.finish()
                }

                override fun onInterrupt(postcard: Postcard?) {
                    //拦截
                }
            })

        }
    }

    override fun initData() {

    }

    override fun getLayout(): Int  = R.layout.fragment_blank3

}